﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Core.Persistent;

namespace Huirui.Cavan.Domain.Seedwork
{
    [Serializable]
    public abstract class Persistent : Persistent<int>
    {
        
    }

    [Serializable]
    public abstract class Persistent<TID> : PersistentObjectWithTypedId<TID>
    {
        protected byte[] _version;

        public virtual byte[] Version 
        {
            get
            {
                return _version;
            }
            set
            {
                _version = value;
            }
        }

        #region String representation
        /// <summary>
        ///     ToString is not used for Catharsis purposes. 
        ///     For debug it is usefull to quickly see the real instance of the object 
        ///     (instaed of the Type name).
        ///     If ToString() is needed another way - override it
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "ID: " + Id + " - " + ToDisplay();
        }
        #endregion String representation

        public override string ToDisplay()
        {
            return Id.ToString();
        }

        protected override string GetDomainObjectSignature()
        {
            return Id.ToString();
        }
    }
}
